home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48hor1 / schip.doc < prev    next >
Text File  |  1995-03-31  |  8KB  |  200 lines

  1. (Comp.sys.handhelds) 
  2. Item: 3286 by erikmb at etek.chalmers.se 
  3. Author: [Erik Bryntse] 
  4.   Subj: SUPER-CHIP v1.1 (now with scrolling) 
  5.   Date: Tue May 28 1991 
  6.  
  7. Ok, here are a new version of S-CHIP. It is a lot faster than version 
  8. 1.0 and have some new scroll functions. And it's still small! 
  9.  
  10. I have copied parts of the original CHIP-48 documentation and added the 
  11. new functions that are available in S-CHIP.  
  12.  
  13. If you would like to start writing games for CHIP, read this, get yourself  
  14. an assembler, look at someone else's program and get started! It's not  
  15. difficult, you can get something up and working in just an hour or so.  
  16. And you get the benefits of machine code - the speed - without having  
  17. to learn all the internals of the 48. And it won't crash when you do  
  18. something wrong (I hope...). 
  19.  
  20. ... and by the way, H. Piper is exactly the kind of super fantastic 
  21. games that I would like to see more of. Good work! 
  22.  
  23.  
  24. SUPER-CHIP v1.1 
  25. =============== 
  26.  
  27. ... a modified version of the CHIP-8 game interpreter originally 
  28. made by Andreas Gustafsson. 
  29.  
  30. S-CHIP offers: 
  31.  
  32. - full screen resolution in new extended screen mode 
  33. - downward compability (you can run your old CHIP games) 
  34. - higher speed in extended mode 
  35. - a larger 16x16 sprite available 
  36. - new, larger fonts for scores 
  37. - you can pass information to and from a S-CHIP program 
  38. - programmable exit from the S-CHIP interpreter possible 
  39. - no need to turn off the clock 
  40. - it will always start 
  41. - instructions to scroll the screen down, left, and right 
  42.  
  43.  
  44. Introduction to CHIP 
  45. -------------------- 
  46.  
  47. For those who don't remember, the CHIP-8 programming language was 
  48. used in a number of home computers based on RCA's CDP1802 pro- 
  49. cessor in the late 1970's.  It's a small, interpreted language 
  50. designed specifically  for writing simple video games.  It has 
  51. less than 40 instructions, including arithmetic, control flow, 
  52. graphics, and sound.  The instructions are all 16 bits long and 
  53. are executed by a very compact virtual machine interpreter (the 
  54. 1802 implementation was 512 bytes long). 
  55.   
  56.  
  57. Technical specification  
  58. ----------------------- 
  59.  
  60. The CHIP-8 virtual machine is byte-addressable and has an address 
  61. space of 4 kB at addresses 000-FFF hex.  However, addresses 
  62. 000-1FF are reserved (this is where the CHIP-8 interpreter used to 
  63. reside). Therefore, the CHIP-8 program itself begins at address 
  64. 200. All instructions are 16 bits long and by convention instruc- 
  65. tions always start at an even address.  
  66.   
  67. The machine has 16 8-bit general-purpose registers called V0..VF.  
  68. The VF register is modified by certain instructions and works as a 
  69. carry flag and sprite collision indicator.  There is also a 16-bit 
  70. pointer register I (though only the low 12 bits are generally 
  71. used).  
  72.   
  73. A CHIP-8 program displays graphics by drawing sprites that are 8  
  74. pixels wide and 1..15 pixels high.  The screen resolution is 32 by 
  75. 64 pixels in standard mode.  The origin is the upper left corner 
  76. of the screen, and all coordinates are positive.  The sprites are 
  77. stored in bigendian format, i.e., the most significant bit corre- 
  78. sponds to the leftmost pixel. All drawing is done in XOR mode. If 
  79. this causes one or more pixels to be erased, VF is <> 00, other- 
  80. wise 00. 
  81.  
  82. In extended screen mode the resolution is 64 by 128 pixels. A 
  83. sprite of 16x16 size is available.  
  84.   
  85. There are two timers: the delay timer and the sound timer.  Both  
  86. timers count down about 60 times per second when nonzero; the 
  87. speaker will beep whenever the sound timer is nonzero.  
  88.   
  89. In the instruction table below, NNN is a 12-bit address, KK is an  
  90. 8-bit constant, and X and Y are 4-bit register numbers.  Hex  
  91. characters represent themselves.  The two first characters of the  
  92. instruction code form the lower-address byte of the instruction, 
  93. the first character being the more significant nibble.  
  94.   
  95. Instructions marked with (*) are new in SUPER-CHIP. 
  96.  
  97. 00CN*    Scroll display N lines down 
  98. 00E0     Clear display  
  99. 00EE     Return from subroutine 
  100. 00FB*    Scroll display 4 pixels right 
  101. 00FC*    Scroll display 4 pixels left 
  102. 00FD*    Exit CHIP interpreter 
  103. 00FE*    Disable extended screen mode 
  104. 00FF*    Enable extended screen mode for full-screen graphics 
  105. 1NNN     Jump to NNN  
  106. 2NNN     Call subroutine at NNN  
  107. 3XKK     Skip next instruction if VX == KK  
  108. 4XKK     Skip next instruction if VX <> KK  
  109. 5XY0     Skip next instruction if VX == VY  
  110. 6XKK     VX := KK  
  111. 7XKK     VX := VX + KK  
  112. 8XY0     VX := VY, VF may change  
  113. 8XY1     VX := VX or VY, VF may change  
  114. 8XY2     VX := VX and VY, VF may change  
  115. 8XY3     VX := VX xor VY, VF may change 
  116. 8XY4     VX := VX + VY, VF := carry  
  117. 8XY5     VX := VX - VY, VF := not borrow  
  118. 8XY6     VX := VX shr 1, VF := carry  
  119. 8XY7     VX := VY - VX, VF := not borrow 
  120. 8XYE     VX := VX shl 1, VF := carry  
  121. 9XY0     Skip next instruction if VX <> VY  
  122. ANNN     I := NNN  
  123. BNNN     Jump to NNN+V0  
  124. CXKK     VX := pseudorandom_number and KK  
  125. DXYN*    Show N-byte sprite from M(I) at coords (VX,VY), VF := 
  126.          collision. If N=0 and extended mode, show 16x16 sprite. 
  127. EX9E     Skip next instruction if key VX pressed  
  128. EXA1     Skip next instruction if key VX not pressed  
  129. FX07     VX := delay_timer  
  130. FX0A     wait for keypress, store hex value of key in VX  
  131. FX15     delay_timer := VX  
  132. FX18     sound_timer := VX  
  133. FX1E     I := I + VX  
  134. FX29     Point I to 5-byte font sprite for hex character VX  
  135. FX30*    Point I to 10-byte font sprite for digit VX (0..9) 
  136. FX33     Store BCD representation of VX in M(I)..M(I+2)  
  137. FX55     Store V0..VX in memory starting at M(I)  
  138. FX65     Read V0..VX from memory starting at M(I)  
  139. FX75*    Store V0..VX in RPL user flags (X <= 7) 
  140. FX85*    Read V0..VX from RPL user flags (X <= 7)  
  141.  
  142.   
  143. Notes on the HP48SX implementation   
  144. ---------------------------------- 
  145.  
  146. CHIP-8 programs are stored in the HP48SX as string objects con- 
  147. taining the bytes of the program in increasing address order, 
  148. beginning with the byte at 0200.  The interpreter itself is a 
  149. machine code object that should be run with the CHIP-8 program 
  150. string on level 1. 4 kB of free memory is needed.  If an error is 
  151. detected during execution, the address of the current CHIP-8 
  152. instruction is returned as a binary integer on level 1.  
  153.   
  154. To quit, press the backspace key.  Pressing ENTER restarts the 
  155. CHIP-8 program, and the +/- key turns the sound off or on.  
  156.   
  157. Subroutine nesting is limited to 16 levels.  
  158.   
  159. Most chip-8 programs are written for a 16-key hex keyboard with   
  160. following layout:  
  161.   
  162.   1 2 3 C                                               7 8 9 /  
  163.   4 5 6 D    This keyboard is emulated on the HP48SX    4 5 6 *  
  164.   7 8 9 E    using the following keys:                  1 2 3 -  
  165.   A 0 B F                                               0 . _ +  
  166.   
  167. This may cause some confusion with programs requiring numerical 
  168. input.  
  169.   
  170.  
  171. Copyrights, etc 
  172. --------------- 
  173.  
  174. Parts of this document is copied from the original CHIP-48 docu- 
  175. mentation written by Andreas Gustafsson. Below is the original 
  176. copyright message for CHIP-48 v2.25 
  177.  
  178. (c) Copyright 1990 Andreas Gustafsson 
  179.  
  180. Noncommercial distribution allowed, provided that this copyright 
  181. message is preserved, and any modified versions are clearly marked 
  182. as such. 
  183.  
  184. The program makes use of undocumented low-level features of the 
  185. HP48SX calculator, and may or may not cause loss of data, ex- 
  186. cessive battery drainage, and/or damage to the calculator hard- 
  187. ware. The author takes no responsibility whatsoever for any damage 
  188. caused by the use of this program. 
  189.  
  190. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESSED OR 
  191. IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
  192. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PUR- 
  193. POSE. 
  194.  
  195.  
  196. The modifications from CHIP v2.25 to S-CHIP v1.1 is made by  
  197.  
  198. Erik Bryntse 
  199. (erikmb@etek.chalmers.se) 
  200.